#include <iostream>
#include <unistd.h>
#include <pthread.h>
#include <cstdio>

int *p = nullptr;

void *threadrun(void *args)
{
    int a = 428;
    p = &a;
    while(true) {sleep(1);}
}

int main()
{
    pthread_t tid;
    pthread_create(&tid,nullptr,threadrun,nullptr);

    while(true)
    {
        sleep(5);
        std::cout << "*p: " << *p << std::endl;
    }

    pthread_join(tid,nullptr);
    return 0;
}
